# -*- coding: utf-8 -*-
import os
import sys
import random
import skills

class Mk_soldier(object):
    def __init__(self, soldier_name):
        self.soldier_name = soldier_name.title()
        self.blood = int(1000 + 100 * random.random())
        self.magic = 0
        self.dizziness_stu = 0
        self.silence_stu = 0

        self.poison_stu = 0
        self.luck = int(1000 * random.random())
        self.all_skills_name = ['double_hit','get_dizziness','get_silence','get_poison','get_health']

    def health_discribe(self):
        if self.dizziness_stu > 0:
            print('\033[35m%s\033[0m is in Dizziness Zzz~ and left \033[34m%s\033[0m time!' % (self.soldier_name.title(), self.dizziness_stu))
        if self.silence_stu > 0:
            print('\033[35m%s\033[0m is in Silence and left \033[34m%s\033[0m time ... ...' % (self.soldier_name.title(), self.silence_stu))
        if self.poison_stu > 0:
            print('\033[35m%s\033[0m is in Poison @#$~ and left \033[34m%s\033[0m time!' % (self.soldier_name.title(), self.poison_stu))
        print('\033[35m%s\033[0m\'s blood and magic :\n\tblood:\033[32m%s\033[0m\tmagic:\033[34m%s\033[0m \n' % (self.soldier_name.title(), self.blood, self.magic))

    def death_discribe(self,sufferer=''):
        if sufferer == '':
            print("KO!the \033[35m%s\033[0m blood is \033[31m0\033[0m ! \033[35m%s\033[0m is dead !" % (self.soldier_name.title(), self.soldier_name.title()))
        else:
            print("KO!the \033[35m%s\033[0m blood is \033[31m0\033[0m ! \033[35m%s\033[0m is dead !" % (sufferer, sufferer))
        return 0

    def winner_discribe(self):
        print("congratulation \033[35m%s\033[0m !you are winner !" % self.soldier_name.title())

    def get_hurt(self):
        num = int(100 * random.random())
        return num

    # hit
    def pk_info(self, sufferer_blood, aggressor, sufferer):
        hurt_n = self.get_hurt()
        print("\033[35m%s\033[0m hit \033[31m%s\033[0m to \033[35m%s\033[0m !" % (aggressor, str(hurt_n), sufferer))
        if sufferer_blood > hurt_n:
            sufferer_blood -= hurt_n
            print("\033[35m%s\033[0m blood losing : \033[31m%s\033[0m" % (sufferer, hurt_n))
            print("\033[35m%s\033[0m left blood : \033[32m%s\033[0m" % (sufferer, sufferer_blood))
            return sufferer_blood
        else:
            return 0


class Superman(Mk_soldier):
    def __init__(self,soldier_name):
        super(Superman,self).__init__(soldier_name)
        self.skills = self.all_skills_name


class Hurter(Mk_soldier):
    def __init__(self,soldier_name):
        super(Hurter,self).__init__(soldier_name)
        self.skills = random.sample(self.all_skills_name,2)

class Boss_vampire(Mk_soldier):
    def __init__(self, soldier_name):
        super(Boss_vampire, self).__init__(soldier_name)
        self.skills = ['suck_blood']

    def suck_blood(self,aggressor_blood, sufferer_blood, aggressor, sufferer):
        hurt_n = self.get_hurt()
        suck_n = 0.5 * hurt_n
        print("\033[35m%s\033[0m suck \033[31m%s\033[0m to \033[35m%s\033[0m !" % (aggressor, str(hurt_n), sufferer))
        if sufferer_blood > hurt_n:
            sufferer_blood -= hurt_n
            print("\033[35m%s\033[0m blood losing : \033[31m%s\033[0m" % (sufferer, hurt_n))
            print("\033[35m%s\033[0m left blood : \033[32m%s\033[0m" % (sufferer, sufferer_blood))
            aggressor_blood += suck_n
            print("\033[35m%s\033[0m get health \033[32m%s\033[0m" % (aggressor, suck_n))
            print("\033[35m%s\033[0m left blood : \033[32m%s\033[0m" % (aggressor, aggressor_blood))
            return aggressor_blood,sufferer_blood
        else:
            return aggressor_blood,0


